﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace CPPEI.Coolzon.Designer.Views
{
    public static class BringToFrontCommand
    {
        public static void Executed(object sender, ExecutedRoutedEventArgs e)
        {
            BringToFrontOperation operation = new BringToFrontOperation(UIContext.Current.CurrentDesignView, UIContext.Current.CurrentDesignView.API_GetSelectedPart());
            OperationCenter.Instance.Do(operation);
        }
        public static void CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (UIContext.Current.CurrentDesignView != null && UIContext.Current.CurrentDesignView.API_IsEditable())
            {
                Coolzon.UI.Part selectedPart = UIContext.Current.CurrentDesignView.API_GetSelectedPart();
                if (selectedPart != null && !(selectedPart is Coolzon.UI.ScenePart) && (selectedPart.ParentPart as Coolzon.UI.IPartContainer).GetPartList().Count > 1)
                {
                    e.CanExecute = true;
                }
                else
                {
                    e.CanExecute = false;
                }
            }
            else
            {
                e.CanExecute = false;
            }
        }
    }
}
